from infra.handler import BaseHandler
from common.config import cfg
import TLSSigAPIv2
class GetIMUserSigHandler(BaseHandler):

    def get(self):
        user_id = self.get_argument('user_id', default=None)
        if user_id is None:
            self.write({'code':404,'msg': 'user_id is None'})
            return
        sig_api = TLSSigAPIv2.TLSSigAPIv2(cfg['im_sdk_appid'], cfg['im_sdk_key'])
        sig = sig_api.gen_sig(user_id)
        self.write({'code':200,'msg': sig})